package play_card;

/**
 * @author : niu niu
 * @version : 1.0.0
 * @date : 2022/10/11 19:36
 */
public class Card {
    private final int rank; //1-13,A->K
    private final String suit; //花色♥、♣、♦、♠

    public Card(String suit, int rank) {
        this.suit = suit;
        this.rank = rank;
    }

    public String toString(){
        // 格式化 String.format
        return String.format("扑克[%s %s]",this.suit,rankStr());
    }

    private String rankStr(){
        if (rank == 1) {
            return "A";
        } else if (rank >= 2 && rank <= 10) {
            return String.valueOf(rank);
        } else if (rank == 11) {
            return "J";
        } else if (rank == 12) {
            return "Q";
        } else {
            return "K";
        }
    }
    public static void main(String[] args) {
        Card card = new Card("♥", 11);
        System.out.println(card);   // card.toString()
    }
}
